import Vue from 'vue'
import App from '@/App.vue'
import store from '@/store'
import router from '@/router'

import '@/styles/element-variables.scss'
import '@/styles/index.scss'

import i18n from '@/lang'
import '@/pwa/register-service-worker'

import '@/plugins/index'

import '@/icons/components'
import SvgIcon from 'vue-svgicon'
import VueNativeSock from 'vue-native-websocket'

Vue.use(SvgIcon, {
  tagName: 'svg-icon',
  defaultWidth: '1em',
  defaultHeight: '1em'
})

Vue.config.productionTip = false

console.log(window.location.host)

Vue.use(VueNativeSock, `ws://${window.location.host}/socket`, {
  reconnection: true, // (Boolean) whether to reconnect automatically (false)
  reconnectionAttempts: 5, // (Number) number of reconnection attempts before giving up (Infinity),
  reconnectionDelay: 3000 // (Number) how long to initially wait before attempting a new (1000)
})

Vue.config.errorHandler = (err: Error) => {
  console.log(err.message)
}

Vue.config.warnHandler = (msg, vm, trace) => {
  const ignoreMsg = [
    'Invalid prop type: "[object Object]" is not a constructor'
  ]
  if (!ignoreMsg.includes(msg)) {
    console.warn(`Warn: ${msg}\nTrace: ${trace}`)
  }
}

new Vue({
  router,
  store,
  i18n,
  render: (h) => h(App)
}).$mount('#app')
